package br.ufpe.cin.imlm2.jbeat.soot.common.filters;

import soot.SootClass;
import soot.SootMethod;
import br.ufpe.cin.imlm2.jbeat.soot.throwableset.tags.ThrowableSetTag;

/**
 * Retains exception classes (<code>SootClass</code> objects) based on whether
 * or not they are part of the GeneratedSet of a method (if they are also NOT in
 * the thrown or propagated exceptions).
 * 
 * @author Irineu
 */
public class GeneratedExceptionsFilter extends ThrowableFilter {

	private SootMethod	method;

	/**
	 * @param meth
	 */
	public GeneratedExceptionsFilter( SootMethod meth ) {
		this.method = meth;
	}

	@Override
	public boolean retains( SootClass t ) {
		if ( super.retains( t ) && this.method.hasTag( ThrowableSetTag.TAG_NAME ) ) {
			ThrowableSetTag tst = (ThrowableSetTag) this.method.getTag( ThrowableSetTag.TAG_NAME );
			return tst.getAllGeneratedExceptions().contains( t )
					&& !tst.getAllPropagatedExceptions().contains( t )
					&& !tst.getAllThrownExceptions().contains( t );
		}
		return false;
	}
}
